#ifndef __USER_SMG_H
#define __USER_SMG_H

#include "main.h"
#include "stm32f0xx_hal.h"
#include "tim.h"
#include "gpio.h"

#define SMG_WEI_NUMBER  4
#define SMG_MAX_LIGHTENESS   3
#define DIS_BUF_SIZE  18      //滚动显示最多显示10个数字

#define SMG_DIS_MODE_NORMAL    0X00
#define SMG_DIS_MODE_ROLL      0X01

#define SMG_S0   0
#define SMG_S1   1 
#define SMG_S2   2
#define SMG_S3   3
#define SMG_S_NONE DIS_BUF_SIZE
#define SMG_S_ALL  DIS_BUF_SIZE+1



class smgClass
{
	public:
        
        void init();
        void scan(void);

        void setDisMode(uint8_t mode);
        uint8_t setNormalDisNumber(uint8_t *s,uint8_t length);
        uint8_t setRollDisNumber(uint8_t *s,uint8_t length);				
        uint8_t setLighteness(uint8_t l);
        uint8_t setOneBitNumber(uint8_t s,uint8_t d);
        uint8_t setOneBitCode(uint8_t s,uint8_t d);               
        uint8_t setBlinkOneBit(uint8_t s);
        void clearBlink(void);
        void clearDis();
        
    
    private:
        uint8_t setDisWei(uint8_t s);
        void normalScan();
        void rollScan();
        uint8_t setOneBitLighteness(uint8_t s,uint8_t l);

				uint8_t disMode;
        uint8_t lighteness;
        uint8_t disBuf[DIS_BUF_SIZE];
        uint8_t blinkTab[SMG_WEI_NUMBER];
        uint8_t rollOffset;      //记录数码管滚动偏移
        uint8_t rollNumber;      //要滚动显示的数量
};

extern smgClass smg;

#endif

